package com.iplant.aps.serviceImpl.dao.mrp;

import com.iplant.base.po.OutResult;
import com.iplant.base.po.Pagination;
import com.iplant.base.utils.annotation.dao.DBBaseDAO;
import com.iplant.base.utils.general.StringUtils;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bms.BMSEmployee;
import com.iplant.aps.service.po.mrp.MRPMaterialItem;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@DBBaseDAO(MRPMaterialItem.class)
@Slf4j
public class MRPMaterialItemDAO extends BaseDAO {

    private static MRPMaterialItemDAO Instance = null;

    public static MRPMaterialItemDAO getInstance() {
        if (Instance == null) {
            Instance = new MRPMaterialItemDAO();
        }
        return Instance;
    }

    public MRPMaterialItemDAO() {
        super("");
        this.Init();
    }


    public void MRP_DeleteMaterialItemByPlanIDList(BMSEmployee wLoginUser, List<Integer> wPlanIDList, OutResult<Integer> wErrorCode){
        if(wPlanIDList==null||wPlanIDList.size()==0)
            return;
        this.Delete("ID>0 ", StringUtils.Format("AND PlanID IN ({0})",StringUtils.Join(",",wPlanIDList)));
    }


    public void MRP_DeleteMaterialItemByIDList(BMSEmployee wLoginUser, List<Integer> wIDList, OutResult<Integer> wErrorCode){
        if(wIDList==null||wIDList.size()==0)
            return;
        this.Delete("ID>0 ", StringUtils.Format("AND ID IN ({0})",StringUtils.Join(",",wIDList)));
    }


    public List<MRPMaterialItem> MRP_SelectMaterialItemByPlanIDList(BMSEmployee wLoginUser, List<Integer> wPlanIDList, Pagination wPagination, OutResult<Integer> wErrorCode) {

        if(wPlanIDList==null||wPlanIDList.size()==0)
            return new ArrayList<>();

        Map<String,Object> wParams=new HashMap<>();

        wParams.put("PlanID", wPlanIDList);

        return this.SelectPOList(wLoginUser, wParams, wPagination, wErrorCode);
    }



}
